package net.sunofbeach.blog.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2 配置类
 *
 * @author bing_  @create 2021/11/23-23:39
 * 访问： http://localhost:2021/doc.html
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    public static final String VERSION = "1.0.0";

    @Bean
    public Docket portalApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(portalApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("net.sunofbeach.blog.controller"))
                .paths(PathSelectors.any())
                .build()
                .groupName("阳光沙滩接口文档");
    }

    private ApiInfo portalApiInfo() {
        return new ApiInfoBuilder()
                .title("阳光沙滩博客系统门户接口文档")
                .description("门户接口文档")
                .version(VERSION)
                .build();
    }

    //@Bean
    //public Docket adminApi() {
    //    return new Docket(DocumentationType.SWAGGER_2)
    //            .apiInfo(adminApiInfo())
    //            .select()
    //            .apis(RequestHandlerSelectors.basePackage("net.sunofbeach.blog.controller.admin"))
    //            .paths(PathSelectors.any())
    //            .build()
    //            .groupName("管理中心");
    //}
    //
    //private ApiInfo adminApiInfo() {
    //    return new ApiInfoBuilder()
    //            .title("阳光沙滩博客系统管理中心接口文档")
    //            .description("管理中心接口文档")
    //            .version(VERSION)
    //            .build();
    //}
    //
    //
    //@Bean
    //public Docket UserApi() {
    //    return new Docket(DocumentationType.SWAGGER_2)
    //            .apiInfo(userApiInfo())
    //            .select()
    //            .apis(RequestHandlerSelectors.basePackage("net.sunofbeach.blog.controller.user"))
    //            .paths(PathSelectors.any())
    //            .build()
    //            .groupName("用户中心");
    //}
    //
    //private ApiInfo userApiInfo() {
    //    return new ApiInfoBuilder()
    //            .title("阳光沙滩博客系统用户接口")
    //            .description("用户接口文档")
    //            .version(VERSION)
    //            .build();
    //}
}